﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ComicIsland.Common;
using ComicIsland.Common.Entities.InterfaceJson;
using ComicIsland.Common.StorageHelper;

/**
 * 创建时间：2015/1/13 18:18:37
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.App.CIHelper
{
    public class LocalHotComicHelper
    {
        public LocalHotComicHelper()
        { }

        /// <summary>
        /// 获取10条热点漫画
        /// </summary>
        /// <returns></returns>
        public ObservableCollection<ComicsList> GetHotComics()
        {
            if (!IsolatedStorageHelper.Instance.FileExists(KEYS.KEY_CacheJsonHotComic))
                return null;

            string localCacheData = IsolatedStorageHelper.Instance.ReadText(KEYS.KEY_CacheJsonHotComic);
            if (string.IsNullOrWhiteSpace(localCacheData))
                return null;
            var result = JSONHelper.Deserialize<JsonChannelMoreBase>(localCacheData);
            if (result != null && result.Info != null && result.Info.ComicsList != null && result.Info.ComicsList.Count > 0)
            {
                return result.Info.ComicsList;
            }
            return null;
        }
    }
}
